//
//  MHAuditListViewController.m
//  MiaoCircle
//
//  Created by 许正荣 on 2018/5/10.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHAuditListViewController.h"
#import "MHAuditTableViewCell.h"
#import "MHAuditListViewModel.h"
#import "MHAuditItemViewModel.h"


@interface MHAuditListViewController ()
@property(nonatomic, strong) MHAuditListViewModel *viewModel;
@end

@implementation MHAuditListViewController
@dynamic viewModel;


- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView mh_registerNibCell:MHAuditTableViewCell.class];
    self.tableView.estimatedRowHeight= 60;
    self.tableView.rowHeight=UITableViewAutomaticDimension;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath{
    
    return [tableView dequeueReusableCellWithIdentifier:@"MHAuditTableViewCell"];
}

- (void)configureCell:(MHAuditTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object{
    MHAuditItemViewModel *itmeViewModel = object;
    @weakify(self);
    [cell.auditBtn bk_whenTapped:^{
        @strongify(self);
       MHAuditItemViewModel *item = self.viewModel.dataSource[indexPath.row];
        [self.viewModel.auditCommand execute:item.model];
    }];
    [cell bindViewModel:object];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
